<?php

namespace app\common\model;

use think\Model;

class Liquor extends Model
{
    protected $insert = ['ctime', 'status' => 'deposit', 'expire_time'];
    
    protected function setCtimeAttr()
    {
        return time();
    }
    
    protected function setExpireTimeAttr()
    {
        $expire = strtotime(date('Y-m-d 00:00:00', time()))+15*86400;
        return $expire;
    }

        public function goods()
    {
        return $this->hasOne('Goods', 'id', 'goods_id')->field(['id', 'name', 'image_id']);
    }
    
    public function user()
    {
        return $this->hasOne('User', 'id', 'user_id')->field(['id', 'avatar', 'nickname', 'password']);
    }
}
